package com.ss.android.j;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.SparseArray;

import com.ss.android.article.browser.R;

public final class c {
    static final boolean isAboveLOLLIPOP;
    private static final SparseArray THEME_ARRAY;

    static {
        isAboveLOLLIPOP = Build.VERSION.SDK_INT >= 21;
        if(isAboveLOLLIPOP) {
            THEME_ARRAY = new SparseArray();
            THEME_ARRAY.put(R.style.Theme_Light_NoActionBar, Integer.valueOf(R.style.Theme_Light_NoActionBar));
            THEME_ARRAY.put(R.style.Theme_Transparent, Integer.valueOf(R.style.Theme_Transparent));
            THEME_ARRAY.put(R.style.Theme_Video, Integer.valueOf(R.style.Theme_Video));
        } else {
            THEME_ARRAY = null;
        }
    }

    public static boolean isAboveLOLLIPOP() {
        return c.isAboveLOLLIPOP;
    }

    static int a(int arg1) {
        if(c.THEME_ARRAY != null) {
            com.ss.android.j.b.isNightModeToggled();
        }
        return arg1;
    }

    public static Drawable getClickableBackgroundDrawable(Context content) {
        return c.getBackgroundDrawable(content, R.style.Clickable);
    }

    private static Drawable getBackgroundDrawable(Context context, int styleResId) {
        Drawable drawable = null;
        if(context != null && styleResId > 0) {
            TypedArray typedArray = context.obtainStyledAttributes(styleResId, new int[]{android.R.attr.background});
            if(typedArray != null) {
                drawable = typedArray.getDrawable(0);
                typedArray.recycle();
            }
        }
        return drawable;
    }
    public static Drawable getClickableBorderlessBackgroundDrawable(Context context) {
        return c.getBackgroundDrawable(context, R.style.ClickableBorderless);
    }
}

